package cn.donting.jme.expansion.attribute.lmpl;

import lombok.extern.slf4j.Slf4j;

import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

@Slf4j
public class BooleanAttribute extends AbsLineAttribute<Boolean,JCheckBox> implements ChangeListener{

    public BooleanAttribute(String title) {
        this();
        setTitle(title);

    }
    public BooleanAttribute() {
        super(new JCheckBox());
        setValue(false);
        inputComponent.addChangeListener(this);
    }

    @Override
    public void setValue(Boolean value) {
        inputComponent.setSelected(value);
    }


    @Override
    protected Boolean getInputValue() {
        return inputComponent.isSelected();
    }


    @Override
    public void stateChanged(ChangeEvent e) {
        valueChange(getValue());
    }
}
